<template>
    <div class="commodity-container">
      <el-row>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item >首页</el-breadcrumb-item>
          <el-breadcrumb-item>业务管理</el-breadcrumb-item>
          <el-breadcrumb-item>商品管理</el-breadcrumb-item>
        </el-breadcrumb>
          <el-form label-width="80px">
            <el-row>
              <el-col :span="5">
                <el-form-item label="商品名" label-width="80px">
                  <el-input size="small" v-model="input" placeholder="请输入内容"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2">
                <el-form-item>
                  <el-button size="small" type="success" icon="el-icon-check" circle></el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
      <div>
      <el-button-group>
        <el-button  size="small" @click="btnAddClick" type="primary" icon="el-icon-edit">添加</el-button>
        <el-button size="small" type="primary" icon="el-icon-share">修改</el-button>
        <el-button size="small" type="primary" icon="el-icon-delete">删除</el-button>
      </el-button-group>
      </div>
      <el-table
        :data="tableData"
        stripe
        style="width: 100%">
        <el-table-column
          prop="commodity"
          label="商品"
          width="180">
        </el-table-column>
        <el-table-column
          prop="sellingPrice"
          label="售价"
          width="180">
        </el-table-column>
        <el-table-column
          prop="saleVolume"
          label="售量"
          width="180">
        </el-table-column>
        <el-table-column
          prop="subtotal"
          label="小计">
        </el-table-column>
      </el-table>
      <el-pagination
        small
        layout="prev, pager, next"
        :total="50">
      </el-pagination>
      </el-row>
      <el-dialog
        title="商品添加"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose">
        <el-form>
          <el-form-group>
            <el-form-item lable-width="80px" lable="商品名">
              <el-input v-model="commodity.name"/>
            </el-form-item>
          </el-form-group>
        </el-form>
        <span class="dialog-footer" slot="footer">
          <el-button @click="dialogVisible = false ">取 消</el-button>
          <el-button @click="sumbmitHandle" type="primary">确 定</el-button>
        </span>
      </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "commodity",
      data() {
        return {
          tableData:[],
          dialogVisible:false,
          commodity:{
            name:'',
            age:'',
            dept:{},
            status:''
          },
          input:'',
          input0:'',
          input1:'',
          tableData: [{
            commodity: '杨枝甘露',
            sellingPrice: '16',
            saleVolume: '213',
            subtotal:'3408'
          }, {
            commodity: '草莓厚芝士',
            sellingPrice: '20',
            saleVolume: '190',
            subtotal:'3800'
          }, {
            commodity: '龙井',
            sellingPrice: '17',
            saleVolume: '106',
            subtotal:'1802'
          }, {
            commodity: '百香金菠萝',
            sellingPrice: '12',
            saleVolume: '58',
            subtotal:'696'
          }, {
            commodity: '芋泥啵啵奶茶',
            sellingPrice: '15',
            saleVolume: '213',
            subtotal:'319'
          }, {
            commodity: '奥利奥奶茶',
            sellingPrice: '14',
            saleVolume: '152',
            subtotal:'2128'
          }]
        }
      },mounted(){
          var _this=this;
          this.axis({
            url:'http://localhost:3000/commodity/list',
            method:'get'
          }).then(function (res) {
            _this.tableData=res.data;

          })
      },methods:{
          handleClose(){
            this.dialogVisible=false;
          },btnAddClick(){
            this.dialogVisible=true;
        }
      }
    }
</script>

<style scoped>

</style>
